<?php 
namespace app\model;

use think\model;

class MenuModel extends Model 
{
    // 设置当前模型对应的完整数据表名称
    protected $table = 'menu';
    // 设置当前模型的数据库连接
    //protected $connection = 'db_config';
    //protected $pk = 'id';

    // 模型初始化
    protected static function init()
    {
        //TODO:初始化内容
    }

    //取得顶层菜单
    public function top_menu(){
        $list1=[
            '0'=>array('id'=>0,'fid'=>0,'name'=>'无父级分类')
        ];
        $list = $this::where('fid',0)->select()->toArray();
        foreach($list as $kv){
            $list1[$kv['id']] = $kv;
        }
        return $list1;

    }


}

